<?php
	$tour_location = TourLocation::retriveByTourAndLocation($tour_id, $location_id);
	$tour = new Tour();
	$tour->select($tour_id);
	$locations = $tour->getAllLocations();
	// now we have to subtract all the index which are bigger than the one we delete
	foreach ($locations as $location) {
		$tl = TourLocation::retriveByTourAndLocation($tour_id, $location->id);
		$index = $tl->getlocation_index();
		if ($index > $tour_location->getlocation_index()) {
			$tl->setlocation_index($index-1);
			$tl->update($tl->getid());
		}
	}
	$tour_location->delete($tour_location->getid());
	admin_load("Xoá Điểm Thành Công", "?act=locations_list_for_tour&tour_id=".$tour_id);	
?>